/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ccedeno
 */
@Entity
@Table(name = "estado_doc", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "EstadoDoc.findAll", query = "SELECT e FROM EstadoDoc e"),
    @NamedQuery(name = "EstadoDoc.findByIdEstadoDoc", query = "SELECT e FROM EstadoDoc e WHERE e.idEstadoDoc = :idEstadoDoc"),
    @NamedQuery(name = "EstadoDoc.findByNombre", query = "SELECT e FROM EstadoDoc e WHERE e.nombre = :nombre")})
public class EstadoDoc implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "id_estado_doc", nullable = false, length = 2)
    private String idEstadoDoc;
    @Size(max = 45)
    @Column(name = "nombre", length = 45)
    private String nombre;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "estadoDoc", fetch = FetchType.LAZY)
    private List<DocAdjunto> docAdjuntoList;

    public EstadoDoc() {
    }

    public EstadoDoc(String idEstadoDoc) {
        this.idEstadoDoc = idEstadoDoc;
    }

    public String getIdEstadoDoc() {
        return idEstadoDoc;
    }

    public void setIdEstadoDoc(String idEstadoDoc) {
        this.idEstadoDoc = idEstadoDoc;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    @XmlTransient
    public List<DocAdjunto> getDocAdjuntoList() {
        return docAdjuntoList;
    }

    public void setDocAdjuntoList(List<DocAdjunto> docAdjuntoList) {
        this.docAdjuntoList = docAdjuntoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEstadoDoc != null ? idEstadoDoc.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EstadoDoc)) {
            return false;
        }
        EstadoDoc other = (EstadoDoc) object;
        if ((this.idEstadoDoc == null && other.idEstadoDoc != null) || (this.idEstadoDoc != null && !this.idEstadoDoc.equals(other.idEstadoDoc))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        //     return "Entidades.EstadoDoc[ idEstadoDoc=" + idEstadoDoc + " ]";
        return idEstadoDoc +" "+"- "+nombre;
    }
}
